package com.wiloon.test.servlet;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by wiloon on 1/3/14.
 */

@WebServlet(
        name = "HelloServlet",
        urlPatterns = "/servlet/HelloServlet",
        asyncSupported = false,
        loadOnStartup = -1,
        displayName = "helloServlet",
        initParams = {@WebInitParam(name = "userName", value = "wiloon", description = "desc test")}

)
public class HelloServlet extends HttpServlet {
    /**
	 * 
	 */
	private static final long serialVersionUID = -4990946201542257607L;
	private static Logger logger = LogManager.getLogger(HelloWorld.class.getName());

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        logger.debug("hello servlet do get.");
        logger.debug("init param:" + this.getInitParameter("userName"));

        response.setContentType("text/html");
        PrintWriter printWriter = response.getWriter();
        printWriter.println("<html><head><title>");
        printWriter.println("This is my first Servlet");
        printWriter.println("</title></head><body>");
        printWriter.println("<h1>Hello, Servlet!</h1>");
        printWriter.println("</body></html>");
    }
}
